package one.stand.task;

import com.jmp.base.dto.LiveTimeoutRequest;
import com.jmp.feign.LiveFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class LiveTask {
    @Autowired
    private LiveFeign liveFeign;

    @Scheduled(cron = "0 */5 * * * ?")
    public void timeout() {
        log.info("live timeout");
        liveFeign.timeout(LiveTimeoutRequest.builder().timeout(30).build());
    }

    /**
     * 短视频可靠回调
     * 腾讯该接口文档：长轮询，请求最多挂起5秒，建议请求方将超时时间设置为10秒
     * 实际测试发现：耗时3s左右，定时任务设为5秒执行一次
     */
    @Scheduled(cron = "*/5 * * * * ?")
    public void video() {
        log.info("video callback");
        liveFeign.videoSaveNotify();
    }
}
